package com.blb.springboot.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blb.springboot.entity.Goods;
import com.blb.springboot.mapper.GoodsMapper;
import com.blb.springboot.service.GoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Resource
    private GoodsMapper goodsMapper;
    @Override
    public void addGoods(Goods goods) {
        goodsMapper.insert(goods);
    }

    @Override
    public void delGoods(long id) {
        goodsMapper.deleteById(id);
    }

    @Override
    public void updateGoods(Goods goods) {
        goodsMapper.updateById(goods);
    }

    @Override
    public IPage<Goods> selectAll(Integer page) {

        IPage<Goods> goodsIPage =goodsMapper.selectPage(new Page<>(page,3),null);
        System.out.println(goodsIPage.getPages());
        return goodsIPage;
    }

}
